const fs = require("fs");
const path = "../waitSloveImg/"
if (fs.existsSync(path)) {
    console.log("true");
    let arr = fs.readdirSync(path);
    let cat = [];
    let last = new Date().getTime();
    let time = 0;
    fs.existsSync("./imgName.text")?fs.unlinkSync("./imgName.text"):true;
    for (let i = 0; i < arr.length; i++) {
        time = last + i;
        last = time;
        let newName = time + "." + arr[i].split(".")[1];
        let catWhite = newName+","+arr[i];
        cat.push(catWhite);
        fs.appendFileSync("./imgName.text",newName+","+arr[i]+"\n");
    }
    for(let value of cat){
        console.log(value.split(","));
        fs.renameSync(path+value.split(",")[1],path+value.split(",")[0]);
    }
}